import axios from 'axios'
import { ElMessage } from 'element-plus'

export const http = axios.create({
  baseURL: 'http://127.0.0.1:8000'
})

/**
 * 响应拦截器
 */
http.interceptors.response.use(config => {
  // 获取响应数据
  const { msg, code } = config.data
  // 判断code是否为0
  if (code !== 0) {
    ElMessage.error(msg)
  }
  return config
})